<template>
	<view class="main" >
		<!-- 标签头部对齐 -->
		<uni-forms :modelValue="baseFormData" label-position="top" label-align="center" label-width="auto">
			<uni-forms-item label="标题" required>
				<uni-easyinput v-model="baseFormData.name" placeholder="请标题" />
			</uni-forms-item>
			<uni-forms-item label="详细内容" required label-align="center">
				<!-- <uni-easyinput autoHeight type="textarea" v-model="" placeholder="输入详细内容"  /> -->
				<uni-easyinput type="textarea" autoHeight v-model="baseFormData.introduction"
					placeholder="请输入内容"></uni-easyinput>
			</uni-forms-item>


		</uni-forms>

		<!-- 标签在左边 -->
		<uni-forms :modelValue="baseFormData" label-align="center" label-width="auto">
			<uni-forms-item label="截至时间">
				<uni-datetime-picker type="datetime" return-type="timestamp" v-model="baseFormData.datetimesingle" />
			</uni-forms-item>
			<uni-forms-item required label="多选">
				<uni-data-checkbox multiple v-model="baseFormData.hobby" :localdata="hobbys" />
			</uni-forms-item>
			<uni-forms-item label="下拉列表">
				<uni-data-select v-model="baseFormData.skills" :localdata="groupOptions"  ></uni-data-select>
			</uni-forms-item>
			<view class="button-group">
				<button type="primary" size="mini" @click="submit()">提交</button>
			</view>
		</uni-forms>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				groupid: "",
				baseFormData: {
					name: '',
					age: '',
					introduction: '',
					hobby: [],
					datetimesingle: 1627529992399,
					skills: ''
				},
				hobbys: [{
					text: '1',
					value: 'a'
				}, {
					text: '2',
					value: "b"
				}, {
					text: '3',
					value: "c"
				}],
				groupOptions: [
				],
			}
		},

		onLoad(options) {
			if (options.id) {
				console.log('接收到的数据：', options.id);
				this.groupid = options.id
			}
	
			this.getGroup()

		},
		methods: {
			getGroup() {
				var groupOptions = [];
				 this.$http({
					url: "/bbservice/bbgroup/getGroupList",
					method: 'GET',
					header: {
						"bbtoken": uni.getStorageSync("localtoken")
					}
				}).then(res => {
					res.data.data.grouplist.forEach(function(res) {
						let group = {
							value: res.id,
							text: res.name
						}
						groupOptions.push(group)
					})
					this.groupOptions = groupOptions

				})
				
				this.isshow = true
			},



			change() {

			},
			submit() {
				console.log(this.groupOptions)
				console.log(this.baseFormData)
			},
			uploadFile(event) {
				const file = event.target.files[0]; // 获取上传的文件
				// 在这里编写上传文件的逻辑
				console.log('上传的文件：', file);
			}

		}
	}
</script>

<style>
	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	,
	.main {
		width: 600rpx;
		margin: auto;
		padding: 20rpx;
		border: 1px solid black;
		border-color: #bbb;
		background: #eee;
		border-radius: 20rpx;
	}

	,
	.text {
		height: 500rpx;

	}
</style>